<template>
	<view class="content">
		<view class="top">
			<image src="../../static/images/chengggong.png" mode=""></image>
			<text class="status">接单成功</text>
			<view class="tips"><text style="color: #999999;">请尽快前往指定地址取件</text><text class="danghang" @tap="openURL(address)">点此导航</text></view>
		</view>
		<view class="bottom">
			<view class="info"><text>取件信息</text>
			</view>
			<view class="detail">
				<text>电话号码:{{info.phone}}</text>
				<text>姓名:{{info.name}}</text>
				<text>取件码:{{info.code}}</text>
			</view>
		</view>
		<view class="btn" @tap="contact()">
			联系客户
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: {

				},
				address:''
			}
		},
		methods: {
			contact() {
				uni.makePhoneCall({
					phoneNumber:this.info.message
				})
			},
			openURL(address) {
				let url = "";
				// #ifdef APP-PLUS
				if (plus.os.name == "Android") {
					var hasBaiduMap = plus.runtime.isApplicationExist({
						pname: 'com.baidu.BaiduMap',
						action: 'baidumap://'
					});
					var hasAmap = plus.runtime.isApplicationExist({
						pname: 'com.autonavi.minimap',
						action: 'androidamap://'
					});
					var urlBaiduMap = "baidumap://map/geocoder?src=andr.baidu.openAPIdemo&address=" + address;
					var urlAmap =
						"androidamap://poi?sourceApplication=softname&keywords="+address;
					if (hasAmap && hasBaiduMap) {
						plus.nativeUI.actionSheet({
							title: "选择地图应用",
							cancel: "取消",
							buttons: [{
								title: "百度地图"
							}, {
								title: "高德地图"
							}]
						}, function(e) {
							switch (e.index) {
								case 1:
									plus.runtime.openURL(urlBaiduMap);
									break;
								case 2:
									plus.runtime.openURL(urlAmap);
									break;
							}
						})
					} else if (hasAmap) {
						plus.runtime.openURL(encodeURI(urlAmap));
					} else if (hasBaiduMap) {
						plus.runtime.openURL(encodeURI(urlBaiduMap));
					} else { 
						plus.runtime.openURL("http://api.map.baidu.com/geocoder?address=" + address + "&output=html&src=kevinproject.cn");
					}
				} else {
					plus.nativeUI.actionSheet({
						title: "选择地图应用",
						cancel: "取消",
						buttons: [{title:"Apple地图"},{
							title: "百度地图"
						}, {
							title: "高德地图"
						}]
					}, function(e) {
						switch (e.index) {
							case 1:
								 url = "http://maps.apple.com/?q="+address;  
								break;
							case 2:
								url = "baidumap://map/geocoder?src=andr.baidu.openAPIdemo&address=" + address;
								break;
							case 3:
								url =
									"iosamap://poi?sourceApplication=campus&name="+address;
								break;
							default:
								break;
						}
						if (url != "") {
							url = encodeURI(url);
							plus.runtime.openURL(url, function(e) {
								plus.nativeUI.alert("本机未安装指定的地图应用");
							});
						}
					})
				}
				// #endif
				// #ifdef MP-WEIXIN
				url = "http://api.map.baidu.com/geocoder?address=" + address + "&output=html&src=kevinproject.cn"
				uni.setClipboardData({
					data: url
				});
				uni.showModal({
					content: '本网址无法直接在小程序内打开。已自动复制网址，请在手机浏览器里粘贴该网址',
					showCancel: false
				});
				// #endif
			}
		},
		onLoad(option) {
			this.info = JSON.parse(option.info);
			this.address = option.address;
		}
	}
</script>

<style>
	page {
		background-color: #f6f6f6;
	}

	.content {
		display: flex;
		flex-direction: column;
		width: 100%;
		align-items: center;
	}

	.top {
		width: 94%;
		height: 400upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 30upx;
		background-color: #ffffff;
	}

	.top image {
		width: 200upx;
		height: 200upx;
	}

	.status {
		font-size: 38upx;
		color: #9DB691;
		font-weight: 600;
		margin-top: 30upx;
	}

	.tips {
		width: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		height: 60upx;
	}

	.tips text {
		font-size: 24upx;
	}

	.danghang {
		margin-left: 20upx;
		color: #2E77ED;
	}

	.bottom {
		width: 94%;
		height: 420upx;
		display: flex;
		flex-direction: column;
		margin-top: 20upx;
		background-color: #ffffff;
		align-items: center;
	}

	.info {
		font-size: 34upx;
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		font-weight: 600;
		width: 100%;
		box-shadow: inset 0px -1px 1px -1px #dcdcdc;
	}

	.detail {
		width: 80%;
		height: 320upx;
		margin-top: 20upx;
		font-size: 28upx;
		color: #999999;
		display: flex;
		padding: 10px;
		flex-direction: column;
		justify-content: center;
	}
	.detail text {
		margin-top: 30upx;
	}
	.btn {
		width: 94%;
		height: 100upx;
		margin-top: 40upx;
		background-color: #EE3F4D;
		color: #ffffff;
		font-size: 30upx;
		text-align: center;
		line-height: 100upx;
	}
</style>
